//============================================================================
// Name        : boundary.cpp
// Author      : dfoelber
//============================================================================

// INCLUDES //
#include "physics/boundary.h"
#include "physics/rectangle.h"
#include <iostream>
//////////////

using namespace std;

/**
* Constructor
**/
Boundary::Boundary() : 
right(RectangleArea(0,0,0,0)) ,
left(RectangleArea(0,0,0,0)) ,
top(RectangleArea(0,0,0,0)) ,
bottom(RectangleArea(0,0,0,0))
{	
}

/**
* Destructor
**/
Boundary::~Boundary()
{
}

/**
* Sets the boundary as a rectangle.
* 
* @param x The new X coordinate
* @param y The new Y coordinate
* @param width The new width
* @param height The new height
**/
void Boundary::SetBoundary( int x, int y, int width, int height )
{
	this->x = x;
	this->y = y;
	this->width = width;
	this->height = height;
	right = RectangleArea(x + width, y, 1000, height);
	left = RectangleArea(x - 1000, y, 1000, height);
	top = RectangleArea(x, y - 1000, width, 1000);
	bottom = RectangleArea(x, y + height, width, 1000);
}

/**
* Gets the X coordinate
* 
* @return The current X coordinate
**/
int Boundary::GetX()
{
	return x;
}

/**
* Gets the Y coordinate
* 
* @return The current Y coordinate
**/
int Boundary::GetY()
{
	return y;
}

/**
* Gets the width
* 
* @return The current width
**/	
int Boundary::GetWidth()
{
	return width;
}

/**
* Gets the height
* 
* @return The current height
**/	
int Boundary::GetHeight()
{
	return height;
}

/**
* Checks the given area and makes sure that it is
* within the boundary. Notifies path on intersection.
* 
* @param path The path to check for intersection
**/
void Boundary::Check( Path* path )
{
	path->CheckCollision( &right, 0, 0 );
	path->CheckCollision( &left, 0, 0 );
	path->CheckCollision( &top, 0, 0 );
	path->CheckCollision( &bottom, 0, 0 );
}
